package top.xzhanyao.scaffold.dashboard.security.service;

import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

import java.util.*;

@Service("userDetailsService")
public class UserDetailsServiceImpl implements UserDetailsService {

	@Override
	public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {

		// 得到用户权限的集合
		Set<String> authoritiySet = new HashSet<>();

		final Collection<SimpleGrantedAuthority> authorities = new ArrayList<>();
		for (String authority : authoritiySet) {
			authorities.add(new SimpleGrantedAuthority(authority));
		}
		return new org.springframework.security.core.userdetails.User("","",
				authorities);
	}

}
